package com.zheng.pvz.model.proxy
{
	import com.zheng.pvz.data.DataConst;
	import com.zheng.pvz.model.vo.DisplayVo;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;
	
	public class DisplayProxy extends EventDispatcher
	{
		public var vo:DisplayVo;
		
		public static const CHANGED_STATUS:String="changed_status";//对象状态改变
		public static const PROXY_DEL:String="proxy_del";//删除这个proxy
		public static const CHANGED_AREA:String="changed_area";//区域改变
		
		public function DisplayProxy(vo:DisplayVo)
		{
			this.vo=vo;
		}
		public function get row():int{
			return vo.row;
		}
		public function get cols():int{
			return vo.cols; 
		}
		public function get status():String{
			return vo.status;
		}
		public function get isHit():Boolean{
			return vo.isHit;
		}
		
		public function set row(value:int):void{
			vo.row=value;
			this.dispatchEvent(new Event(DisplayProxy.CHANGED_AREA));
		}
		public function set cols(value:int):void{
			vo.cols=value;
			this.dispatchEvent(new Event(DisplayProxy.CHANGED_AREA));
		}
		
		public function set isHit(value:Boolean):void{
			vo.isHit=value;
		}
		public function set status(value:String):void{
			vo.status=value;
			if(value==DataConst.STATUS_DEL&&vo.isHit)vo.isHit=false;
			this.dispatchEvent(new Event(DisplayProxy.CHANGED_STATUS));
		}
		
		public function deductBlood():void{
			vo.blood--;
			if(vo.blood<=0){
				status=DataConst.STATUS_DEL;//改变状态为del
				this.dispatchEvent(new Event(DisplayProxy.PROXY_DEL));//删除proxy
			}
		}
		public function position(row:int,cols:int):void{
			vo.row=row;
			vo.cols=cols;
			this.dispatchEvent(new Event(DisplayProxy.CHANGED_AREA));
		}
		
	}
}